Function.prototype.hybind = function (thisArg, ...argArray) {
  var fn = this;

  thisArg =
    thisArg !== null && thisArg !== undefined ? Object(thisArg) : window;

  function proxyFn(...args) {
    thisArg.fn = fn;
    // 特殊：对两个传入的参数进行合并
    var finalArgs = [...argArray, ...args];
    var result = thisArg.fn(...finalArgs);
    delete thisArg.fn;
    return result;
  }

  return proxyFn;
};

function foo() {
  console.log("foo被执行", this);
  return 20;
}

function sum(num1, num2, num3, num4) {
  console.log(this, num1, num2, num3, num4);
}

var bar = sum.hybind("abc", 10, 20);
bar(30, 40);
